<%@ page import="com.nextStep.entity.Users" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>

<html lang="en" dir="ltr">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>mySqlExecute【修改数据】</title>

    <!-- GOOGLE FONTS -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat:400,500|Poppins:400,500,600,700|Roboto:400,500" rel="stylesheet"/>
    <link href="https://cdn.materialdesignicons.com/3.0.39/css/materialdesignicons.min.css" rel="stylesheet" />

    <!-- PLUGINS CSS STYLE -->
    <link href="../plugins/toaster/toastr.min.css" rel="stylesheet" />
    <link href="../plugins/nprogress/nprogress.css" rel="stylesheet" />
    <link href="../plugins/flag-icons/css/flag-icon.min.css" rel="stylesheet"/>
    <link href="../plugins/jvectormap/jquery-jvectormap-2.0.3.css" rel="stylesheet" />
    <link href="../plugins/ladda/ladda.min.css" rel="stylesheet" />
    <link href="../plugins/select2/css/select2.min.css" rel="stylesheet" />
    <link href="../plugins/daterangepicker/daterangepicker.css" rel="stylesheet" />

    <!-- SLEEK CSS -->
    <link id="sleek-css" rel="stylesheet" href="../css/sleek.css" />



    <!-- FAVICON -->
    <link href="../img/favicon.png" rel="shortcut icon" />

    <!--
      HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
    -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <script src="../plugins/nprogress/nprogress.js"></script>
</head>

<%--class="sidebar-fixed sidebar-dark header-light header-fixed"--%>
<body  id="body">
<%--<script>
    NProgress.configure({ showSpinner: false });
    NProgress.start();
</script>--%>

<%--判断是否登录--%>
<%
    if(session.getAttribute("LOGIN_DATA")==null){
        response.sendRedirect("../login.jsp");
        return ;
    }
    Map map = (Map) session.getAttribute("DATABASE_DATA");
    String dbName = (String)session.getAttribute("upRowDb");
    String tbName = (String)session.getAttribute("upRowTb");
    List<List> upRowDa = (List<List>)session.getAttribute("upRowDa");

%>


<div class="mobile-sticky-body-overlay"></div>

<div class="wrapper">

    <div class="page-wrapper">
        <!-- Header -->
        <header class="main-header " id="header">
            <nav class="navbar navbar-static-top navbar-expand-lg">
                <!-- Sidebar toggle button -->
                <%--<button id="sidebar-toggler" class="sidebar-toggle">--%>
                <span class="sr-only">Toggle navigation</span>
                <%--</button>--%>
                <!-- search form -->
                <div class="search-form d-none d-lg-inline-block">
                    <div class="input-group">
                        <button type="button" name="search" id="search-btn" class="btn btn-flat">
                            <i class="mdi mdi-magnify"></i>
                        </button>
                        <input type="text" name="query" id="search-input" class="form-control" value="mysqlExecute 修改数据"
                               autofocus autocomplete="off"  readonly="readonly" style="font-size: 28px"/>
                    </div>
                    <div id="search-results-container">
                        <ul id="search-results"></ul>
                    </div>
                </div>

                <div class="navbar-right ">
                    <ul class="nav navbar-nav">
                        <!-- 菜单栏 -->
                        <li class="dropdown user-menu">
                            <button href="#" class="dropdown-toggle nav-link" data-toggle="dropdown">
                                <img src="../img/user/user.png" class="user-image" alt="User Image" />
                                <span class="d-none d-lg-inline-block"><%=((Users)session.getAttribute("LOGIN_DATA")).getName() %></span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-right">
                                <!-- User image -->
                                <li class="dropdown-header">
                                    <img src="../img/user/user.png" class="img-circle" alt="User Image" />
                                    <div class="d-inline-block">
                                        <%=((Users)session.getAttribute("LOGIN_DATA")).getName()%> <small class="pt-1"><%=((Users)session.getAttribute("LOGIN_DATA")).getEmail()%></small>
                                    </div>
                                </li>
                                <li>
                                    <a href="index"><i class="mdi mdi-account"></i> 主页</a>
                                </li>
                                <li>
                                    <a href="dbConfigAdmin"> <i class="mdi mdi-settings"></i> 数据库配置 </a>
                                </li>
                                <li>
                                    <a href="sqlplus"> <i class="mdi mdi-settings"></i> sqlPlus 命令操作</a>
                                </li>
                                <li class="dropdown-footer">
                                    <a href="../user/exit"> <i class="mdi mdi-logout"></i> 退出 </a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>

            </nav>


        </header>

        <div class="content-wrapper">
           <div class="content">
               <div class="row">
                <div class="col-lg-6">
                    <div class="card card-default">
                        <div class="card-header card-header-border-bottom">
                            <font size="6" >修改数据</font> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br><font size="5" >数据库：</font><h2><a id="dbName" value="<%=dbName%>"><%=dbName%></a></h2> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font size="3.5" >表：</font><h2><a id="tbName" value="<%=tbName%>"><%=tbName%></a></h2>
                        </div>
                        <div class="card-body">
                                <div class="form-row">
                                    <div class="col-md-12 mb-3">
                                        <a name="rowId" value="<%=upRowDa.get(0).get(0) %> " ><%=upRowDa.get(0).get(0) %></a> &nbsp;&nbsp;&nbsp;&nbsp;[ 注：表第一个字段不可修改 ]
                                        <input name="rowValue"  readonly="readonly" type="text" class="form-control" placeholder="<%=upRowDa.get(0).get(0) %>" value="<%=upRowDa.get(1).get(0) %>" />
                                    </div>
                                    <%
                                        for (int i = 1; i < upRowDa.get(0).size() ; i++) {
                                    %>
                                    <div class="col-md-12 mb-3">
                                        <a name="rowId" value="<%=upRowDa.get(0).get(0) %>" ><%=upRowDa.get(0).get(i) %></a>
                                        <input name="rowValue" type="text" class="form-control" placeholder="<%=upRowDa.get(0).get(i) %>" value="<%=upRowDa.get(1).get(i) %>" />
                                    </div>
                                    <%
                                        }
                                    %>
                                </div>
                                <button id="submit" class="btn btn-primary " >修改</button>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <button class="btn btn-primary " onclick="javascript :history.back(-1)" >返回上一层</button>
                       </div>
                    </div>
                </div>

            </div>

            </div>



        </div>

        <jsp:include page="footer.jsp"/>

    </div>


</div>


<script src="../plugins/jquery/jquery.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="../plugins/toaster/toastr.min.js"></script>
<script src="../plugins/slimscrollbar/jquery.slimscroll.min.js"></script>
<script src="../plugins/charts/Chart.min.js"></script>
<script src="../plugins/ladda/spin.min.js"></script>
<script src="../plugins/ladda/ladda.min.js"></script>
<script src="../plugins/jquery-mask-input/jquery.mask.min.js"></script>
<script src="../plugins/select2/js/select2.min.js"></script>
<script src="../plugins/jvectormap/jquery-jvectormap-2.0.3.min.js"></script>
<script src="../plugins/jvectormap/jquery-jvectormap-world-mill.js"></script>
<script src="../plugins/daterangepicker/moment.min.js"></script>
<script src="../plugins/daterangepicker/daterangepicker.js"></script>
<script src="../plugins/jekyll-search.min.js"></script>
<script src="../js/sleek.js"></script>
<script src="../js/chart.js"></script>
<script src="../js/date-range.js"></script>
<script src="../js/map.js"></script>
<script src="../js/custom.js"></script>

<script src="https://code.jquery.com/jquery-2.2.1.min.js"></script>
<script type="text/javascript">


    //查询总页数
    document.getElementById("submit").onclick=function(){
        var dbName = document.getElementById("dbName").innerHTML;  //数据库下拉框对象
        var tbName = document.getElementById("tbName").innerHTML;
        var rowId = document.getElementsByName("rowId")//获取所有name属性值等于‘tbValue’的input
        var rowValue = document.getElementsByName("rowValue")//获取所有name属性值等于‘tbValue’的input
        var arrId=new Array();
        var arrValue = [];
        for(var i=0; i<rowId.length;i++){
            arrId[i] = ( rowId[i].innerText);
           // alert ( rowId[i].innerText);  获取a标签value值
            arrValue[i] = ( rowValue[i].value);
        }

       $.ajax({
            url: "updateRowData",
            type: "post",
            traditional : true,   //传输数组
            data: {dbName: dbName, tbName: tbName,arrId:arrId,arrValue:arrValue},
            success: function (orderColumns) {
                if(orderColumns == 0 ){
                    alert("表结构原因，无法自动生成sql（主键原因），建议使用sql直接插入")
                }
                localStorage.tbName="";
                window.location.href="index";
                //history.go(-1);
            }
        });


    }





</script>




</body>
</html>
